    <div id="breadcrumbs"><?php echo $this->Html->link('Home', array('controller' => 'contents', 'action' => 'view', 'home')); ?> > List Surveys </div>

<?php
//if super admin or admin
if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) {
    ?>
    <div class="surveys index">
        <h2><?php echo __('Surveys'); ?></h2>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th><?php echo $this->Paginator->sort('name'); ?></th>
                <th><?php echo $this->Paginator->sort('created'); ?></th>
                <th>View</th>
                <th>Edit</th>
                <th>Delete</th>
            </tr>
            <?php foreach ($surveys as $survey): ?>
                <tr>
                    <td><?php echo $this->Html->link($survey['Survey']['name'], $survey['Survey']['link']); ?>&nbsp;</td>
                    <td><?php echo $this->Format->dateFormat($survey['Survey']['created']); ?>&nbsp;</td>
                    <td><?php echo $this->Html->image('view.png', array('alt' => 'View', 'url' => array('action' => 'view', $survey['Survey']['id']))); ?></td>
                    <td><?php echo $this->Html->image('edit.png', array('alt' => 'Edit', 'url' => array('action' => 'edit', $survey['Survey']['id']))); ?></td>
                    <td><?php echo $this->Form->postLink($this->Html->image('delete.png', array('alt' => __('Delete'))), array('action' => 'delete', $survey['Survey']['id']), array('escape' => false, 'confirm' => __('Are you sure you want to delete ' . $survey['Survey']['name'] . '?'))); ?></td>		
                </tr>
            <?php endforeach; ?>
        </table>
        <p>
            <?php
            echo $this->Paginator->counter(array(
                'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
            ));
            ?>	</p>
        <div class="paging">
            <?php
            echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
            echo $this->Paginator->numbers(array('separator' => ''));
            echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
            ?>
        </div>
    </div>
    <div class="actions">
        <h3><?php echo __('Actions'); ?></h3>
        <ul>
            <li><?php echo $this->Html->link(__('New Survey'), array('action' => 'add')); ?></li>
        </ul>
    </div>
    <?php
}
//staff view
else {
    ?>
    <h2><?php echo __('Surveys'); ?></h2>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th></th>
            <th><?php echo $this->Paginator->sort('name'); ?></th>
            <th><?php echo $this->Paginator->sort('created'); ?></th>

        </tr>
        <?php foreach ($surveys as $survey): ?>
            <tr>
                <td>
                    <?php
                    $flag = false;
                    if (!empty($surveyUsers)) {
                        foreach ($surveyUsers as $surveyUser):
                            if ($surveyUser['SurveysUser']['survey_id'] == $survey['Survey']['id']) {
                                $flag = true;
                            }
                        endforeach;
                    }
                    
                    if ($flag) {
                        echo $this->Html->image('Check.png', array('alt' => 'isRead', 'url' => array('action' => 'isRead', $survey['Survey']['id'])));
                    } else {
                        echo $this->Html->image('Exclamation.png', array('alt' => 'unRead', 'url' => array('action' => 'unRead', $survey['Survey']['id'])));
                    }
                    
                    ?>
                </td>
                <td><?php echo $this->Html->link($survey['Survey']['name'], array('action' => 'go', '?' => array('link' => $survey['Survey']['link'], 'id' => $survey['Survey']['id']))); ?>&nbsp;</td>
                <td><?php echo $this->Format->dateFormat($survey['Survey']['created']); ?>&nbsp;</td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php } ?>